package com.ruoyi.wq.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wq.mapper.WqPlayMapper;
import com.ruoyi.wq.domain.WqPlay;
import com.ruoyi.wq.domain.vo.WqPlayVO;
import com.ruoyi.wq.service.IWqPlayService;

/**
 * 陪玩类目Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-09-05
 */
@Service
public class WqPlayServiceImpl extends ServiceImpl<WqPlayMapper, WqPlay> implements IWqPlayService {

    @Autowired
    private WqPlayMapper wqPlayMapper;

    /**
     * 查询陪玩类目
     * 
     * @param id 陪玩类目主键
     * @return 陪玩类目
     */
    @Override
    public WqPlay selectWqPlayById(String id)
    {
        return wqPlayMapper.selectWqPlayById(id);
    }

    /**
     * 查询陪玩类目列表
     * 
     * @param wqPlay 陪玩类目
     * @return 陪玩类目
     */
    @Override
    public List<WqPlay> selectWqPlayList(WqPlay wqPlay)
    {
        return wqPlayMapper.selectWqPlayList(wqPlay);
    }

    /**
     * 新增陪玩类目
     * 
     * @param wqPlay 陪玩类目
     * @return 结果
     */
    @Override
    public int insertWqPlay(WqPlay wqPlay)
    {
        wqPlay.setCreateTime(DateUtils.getNowDate());
        return wqPlayMapper.insertWqPlay(wqPlay);
    }

    /**
     * 修改陪玩类目
     * 
     * @param wqPlay 陪玩类目
     * @return 结果
     */
    @Override
    public int updateWqPlay(WqPlay wqPlay)
    {
        wqPlay.setUpdateTime(DateUtils.getNowDate());
        return wqPlayMapper.updateWqPlay(wqPlay);
    }

    /**
     * 批量删除陪玩类目
     * 
     * @param ids 需要删除的陪玩类目主键
     * @return 结果
     */
    @Override
    public int deleteWqPlayByIds(String[] ids)
    {
        return wqPlayMapper.deleteWqPlayByIds(ids);
    }

    /**
     * 删除陪玩类目信息
     * 
     * @param id 陪玩类目主键
     * @return 结果
     */
    @Override
    public int deleteWqPlayById(String id)
    {
        return wqPlayMapper.deleteWqPlayById(id);
    }

	@Override
	public List<WqPlayVO> getList(WqPlayVO wqPlay) {
		wqPlay.setUserId(SecurityUtils.getUserId());
		List<WqPlayVO> playList = baseMapper.getList(wqPlay);
		for(WqPlayVO play : playList){
			if(StringUtils.isBlank(play.getUserPlayId())){
				play.setActive(false);
			}else{
				play.setActive(true);
			}
		}
		return playList;
	}

}
